<!--********************************************************************
* Copyright© 2000 - 2025 SuperMap Software Co.Ltd. All rights reserved.
*********************************************************************-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title data-i18n="resources.title_fieldService"></title>
  <script type="text/javascript" include="bootstrap-css" src="../js/include-web.js"></script>
  <script type="text/javascript" src="../../dist/maplibregl/include-maplibregl.js"></script>
  <style>
    .maplibregl-popup-close-button {
      outline: none;
    }
  </style>
</head>

<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
  <div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
  <script>
    var map,
      baseUrl = (window.isLocal ? window.server : "https://iserver.supermap.io") + "/iserver/services/map-world/rest/maps/World Map/zxyTileImage.png?z={z}&x={x}&y={y}",
      dataUrl = (window.isLocal ? window.server : "https://iserver.supermap.io") + "/iserver/services/data-world/rest/data";
    var attribution = "<a href='https://maplibre.org/' target='_blank'>© MapLibre </a>" +
      " with <span>© <a href='https://iclient.supermap.io' target='_blank'>SuperMap iClient</a> | </span>" +
      " Map Data <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' target='_blank'>SuperMap iServer</a></span> ";

    map = new maplibregl.Map({
      container: 'map',
      style: {
        "version": 8,
        "sources": {
          "raster-tiles": {
            "attribution": attribution,
            "type": "raster",
            "tiles": [baseUrl],
            "tileSize": 256
          }
        },
        "layers": [{
          "id": "simple-tiles",
          "type": "raster",
          "source": "raster-tiles",
        }]
      },
      center: [0, 0],
      zoom: 2
    });
    map.addControl(new maplibregl.NavigationControl(), 'top-left');
    map.addControl(new maplibregl.supermap.LogoControl({ link: "https://iclient.supermap.io" }), 'bottom-right');

    map.on("load", function () {
      mapService();
    });

    function mapService() {
      var param = new maplibregl.supermap.FieldParameters({
        datasource: "World",
        dataset: "continent_T"
      });
      new maplibregl.supermap.FieldService(dataUrl).getFields(param).then(function (serviceResult) {
        var innerHTML = serviceResult.result.fieldNames.join(', ');
        new maplibregl.Popup().setLngLat([0, 0]).setHTML(innerHTML).addTo(map);
      });
    }
  </script>
</body>

</html>
